﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using Tanmia.Basis.Core;
using Tanmia.Basis.ViewModel;

namespace Tanmia.Windows
{
    static class WindowManager
    {
        public static void ShowEditor<TWindow, TCore>(TCore entity)
            where TWindow : Window, new()
            where TCore : BaseBusinessObject, new()
        {
            TWindow window = new TWindow();
            BaseViewModel<TCore> viewModel = window.DataContext as BaseViewModel<TCore>;
            viewModel.Entity = entity;
            window.Show();
        }

        public static void ShowDialogEditor<TWindow>()
            where TWindow : Window, new()
        {
            TWindow window = new TWindow();
            window.ShowDialog();
        }

        public static void ShowWindow<TWindow>()
            where TWindow : Window, new()
        {
            TWindow window = new TWindow();
            window.Show();
        }

        public static void ShowEditor<TWindow, TCore>()
            where TWindow : Window, new()
            where TCore : BaseBusinessObject, new()
        {
            ShowEditor<TWindow, TCore>(new TCore());
        }
    }
}
